﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="wucPostWriter.ascx.cs"
    Inherits="Controls_wucPostWriter" %>
<table width="100%" cellpadding="0" cellspacing="4">
    <tr>
        
        <td align="left" valign="top">
            <table border="0">
                <tr>
                    <td align="left" valign="top">
                        <input id="btnImg" class="button" type="button" value="image" onclick="javascript:SetImage();" style="width:55px; text-align:left;" />
                    </td>
                    <td align="left" valign="top">
                        <input id="btnNewLine" class="button" type="button" value="New Line" onclick="javascript:SetNewLine();" />
                    </td>
                    <td align="left" valign="top">
                        <input id="btnQuote" class="button" type="button" value="Quote" onclick="javascript:SetQuote();" style="width:60px; text-align:left;" />
                    </td>
                     <td align="left" valign="top">
                        <input id="btnLink" class="button" type="button" value="Link" onclick="javascript:SetHyperLink();" style="width:60px; text-align:left;" />
                    </td>
                    <td align="left" valign="top">
                        <input id="btlCleanAll" class="button" type="button" value="Clear All" onclick="javascript:SetCleanText();" />
                    </td>
                    <td align="left" valign="top">
                        <input id="btnBold" class="button" type="button" value="B" onclick="javascript:SetBoldFront();" style="width:30px; text-align:left;" />
                    </td>
                    <td align="left" valign="top">
                        <input id="btnItalic" class="button" type="button" value="I" onclick="javascript:SetItalic();" style="width:30px; text-align:left;"/>
                    </td>
                    <td align="left" valign="top">
                        <input id="btnUnderLine" class="button" type="button" value="U" onclick="javascript:SetUnderLine();" style="width:30px; text-align:left;" />
                    </td>
                </tr>
                <tr>
                </tr>
            </table>
        </td>
        <td>
        </td>
    </tr>
    <tr>
        
        <td align="left" valign="top" width="85%">
            <asp:TextBox ID="txtPostContent" runat="server" Width="100%" TextMode="MultiLine"
                Height="190px"></asp:TextBox>
            <asp:RequiredFieldValidator ID="rfvContent" ControlToValidate="txtPostContent" Display="None"
            runat="server" ErrorMessage="Messages cannot be blank. Ensure your post contains non-whitespace characters and does not consist solely of formatted or quoted text."></asp:RequiredFieldValidator>
        </td>
        <td align="left" valign="top" width="15%">
            <table border="0" cellpadding="0" cellspacing="2">
                <tr>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(1);return false;" title="Arrow">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_arrow.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(2);return false;" title="Very Happy">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_biggrin.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(3);return false;" title="Confused">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_confused.gif") %>' border="0" />
                        </a>
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(4);return false;" title="Cool">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_cool.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(5);return false;" title="Cry">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_cry.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(6);return false;" title="Shocked">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_eek.gif") %>' border="0" />
                        </a>
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(7);return false;" title="Evil">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_evil.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(8);return false;" title="Exclaimation">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_exclaim.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(9);return false;" title="Idea">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_idea.gif") %>' border="0" />
                        </a>
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(10);return false;" title="Laughing">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_lol.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(11);return false;" title="Mad">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_mad.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(12);return false;" title="Mr.Green">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_mrgreen.gif") %>' border="0" />
                        </a>
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(13);return false;" title="Neutral">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_neutral.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(14);return false;" title="Question">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_question.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(15);return false;" title="Razz">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_razz.gif") %>' border="0" />
                        </a>
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(16);return false;" title="Embarassed">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_redface.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(17);return false;" title="Rolling Eyes">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_rolleyes.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(18);return false;" title="Sad">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_sad.gif") %>' border="0" />
                        </a>
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(19);return false;" title="Smile">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_smile.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(20);return false;" title="Surprised">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_surprised.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(21);return false;" title="Twisted Evil">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_twisted.gif") %>' border="0" />
                        </a>
                    </td>
                </tr>
                <tr>
                    <td align="left" valign="top">
                        <a href="" onclick="javascript:SetEmotion(22);return false;" title="Wink">
                            <img src='<%= Page.ResolveUrl("~/Emotions/icon_wink.gif") %>' border="0" />
                        </a>
                    </td>
                    <td align="left" valign="top" colspan="2">
                        <a href="" onclick="javascript:SetEmotion(23);return false;" title="Worshippy">
                            <img src='<%= Page.ResolveUrl("~/Emotions/worshippy.gif") %>' border="0" />
                        </a>
                    </td>
                   
                </tr>
            </table>
        </td>
    </tr>
</table>

<script type="text/javascript">
var imagecounter=0;
var boldcounter=0;
var italiccounter=0;
var quotecounter=0;
var underlinecounter=0;
function CheckTagFormats()
{
    if(imagecounter==1 || boldcounter==1 || italiccounter==1 || quotecounter==1 || underlinecounter==1)
    {
    }
 
}

function SetCleanText()
{
    var txtPostContent= $("#"+"<%= txtPostContent.ClientID  %>"); 
    txtPostContent.val("");    
    imagecounter=0; 
    boldcounter=0;
    italiccounter=0; 
    quotecounter=0;  
    underlinecounter=0;
    
    $("#btnUnderLine").val("U");
    $("#btnQuote").val("Quote");
    $("#btnItalic").val("i");
    $("#btnBold").val("B");
    $("#btnImg").val("image");
}

function SetEmotion(emotionID)
{
    var emotion="";
    var txtPostContent= $("#"+"<%= txtPostContent.ClientID  %>");    
    if(emotionID==1){emotion=":arrow:";}
    else if(emotionID==2){emotion=":D";}
    else if(emotionID==3){emotion=":?";}
    else if(emotionID==4){emotion=":cool:";}
    else if(emotionID==5){emotion=":cry:";}
    else if(emotionID==6){emotion=":eek:";}
    else if(emotionID==7){emotion=":evil:";}
    else if(emotionID==8){emotion=":exclaim:";}
    else if(emotionID==9){emotion=":idea:";}
    else if(emotionID==10){emotion=":lol:";}
    else if(emotionID==11){emotion=":mad:";}
    else if(emotionID==12){emotion=":mrgreen:";}
    else if(emotionID==13){emotion=":neutral:";}
    else if(emotionID==14){emotion=":question:";}
    else if(emotionID==15){emotion=":razz:";}
    else if(emotionID==16){emotion=":redface:";}
    else if(emotionID==17){emotion=":rolleyes:";}
    else if(emotionID==18){emotion=":sad:";}
    else if(emotionID==19){emotion=":smile:";}
    else if(emotionID==20){emotion=":surprised:";}
    else if(emotionID==21){emotion=":twisted:";}
    else if(emotionID==22){emotion=":wink:";}
    else if(emotionID==23){emotion=":worshippy:";}
    
    
    
    txtPostContent.val(txtPostContent.val()+emotion);     
}

function SetUnderLine()
{
    var txtPostContent= $("#"+"<%= txtPostContent.ClientID  %>");    
    if(underlinecounter==0)
    {
        txtPostContent.val(txtPostContent.val()+"[u]");
        $("#btnUnderLine").val("U*");
        underlinecounter=1;
    }
    else
    {
        txtPostContent.val(txtPostContent.val()+"[/u]");
        $("#btnUnderLine").val("U");
        underlinecounter=0;
    }
}

function SetQuote()
{
    var txtPostContent= $("#"+"<%= txtPostContent.ClientID  %>");    
    if(quotecounter==0)
    {
        txtPostContent.val(txtPostContent.val()+"[quote]");
        $("#btnQuote").val("Quote*");
        quotecounter=1;
    }
    else
    {
        txtPostContent.val(txtPostContent.val()+"[/quote]");
        $("#btnQuote").val("Quote");
        quotecounter=0;
    }
}
function SetNewLine()
{
    var txtPostContent= $("#"+"<%= txtPostContent.ClientID  %>");  
    txtPostContent.val(txtPostContent.val()+"[br /]");     
   
}

function SetItalic()
{
    var txtPostContent= $("#"+"<%= txtPostContent.ClientID  %>");    
    if(italiccounter==0)
    {
        txtPostContent.val(txtPostContent.val()+"[i]");
        $("#btnItalic").val("i*");
        italiccounter=1;
    }
    else
    {
        txtPostContent.val(txtPostContent.val()+"[/i]");
        $("#btnItalic").val("i");
        italiccounter=0;
    }
}
function SetBoldFront()
{
    var txtPostContent= $("#"+"<%= txtPostContent.ClientID  %>");    
    if(boldcounter==0)
    {
        txtPostContent.val(txtPostContent.val()+"[b]");
        $("#btnBold").val("B*");
        boldcounter=1;
    }
    else
    {
        txtPostContent.val(txtPostContent.val()+"[/b]");
        $("#btnBold").val("B");
        boldcounter=0;
    }
}

function SetImage()
{
    var txtPostContent= $("#"+"<%= txtPostContent.ClientID  %>");    
    if(imagecounter==0)
    {
        txtPostContent.val(txtPostContent.val()+"[image][");
        $("#btnImg").val("image*");
        imagecounter=1;
    }
    else
    {
        txtPostContent.val(txtPostContent.val()+"][/image]");
        $("#btnImg").val("image");
        imagecounter=0;
    }
}

function SetHyperLink() {
    var url = prompt("Please enter your URL", "http://");
    var txtPostContent = $("#" + "<%= txtPostContent.ClientID  %>");    
   
    if (url != null && url != "" && url!="http://") {
        var description = prompt("Please enter your URL description", "description");

        txtPostContent.val(txtPostContent.val() + "[a href='"+url+"']" + description + "[/a]");
    }
    else {
    alert("URL can't be blank")
    }
}
</script>

